//
//  AppDelegate.m
//  FSH5Pay
//
//  Created by 四维图新科技股份有限公司 on 2022/8/18.
//

#import "AppDelegate.h"
#import "ViewController.h"
#import "InputViewController.h"
#import "WXApi.h"

///微信支付APPID
#define WeChat_APPID @"wx3456136437ac877f"
#define WeChat_UniversalLink @""
@interface AppDelegate ()

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:[inPutViewController new]];
    self.window.rootViewController = nav;
    [self.window makeKeyAndVisible];
    self.window.backgroundColor = [UIColor whiteColor];
    
    [WXApi registerApp:WeChat_APPID universalLink:WeChat_UniversalLink];
    return YES;
}

- (void)applicationDidBecomeActive:(UIApplication *)application{
    
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{
//    if ([url.host isEqualToString:@"apmqpdispatch"]) {
//        [AFServiceCenter handleResponseURL:url withCompletion:^(AFServiceResponse *response) {
//            if (AFResSuccess == response.responseCode) {
//                NSLog(@"%@", response.result);
//            }
//        }];
//    }
    return YES;
}

// NOTE: 9.0以后使用新API接口
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options{
//    if ([url.host isEqualToString:@"apmqpdispatch"]) {
//        [AFServiceCenter handleResponseURL:url withCompletion:^(AFServiceResponse *response) {
//            if (AFResSuccess == response.responseCode) {
//                NSLog(@"%@", response.result);
//            }
//        }];
//    }
    return YES;
}
//- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options{
//    NSString *UrlStr = [url.absoluteString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//    ///支付宝支付
//    if ([UrlStr containsString:@"safepay"]) {
//        UrlStr = [UrlStr stringByReplacingOccurrencesOfString:@"alipayDemo://safepay/?" withString:@""];
//        NSData *jsonData = [UrlStr dataUsingEncoding:NSUTF8StringEncoding];
//        NSError *error;
//        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&error];
//        if (!error) {
//            ///发送支付结果的通知
//            [[NSNotificationCenter defaultCenter]postNotificationName:@"kAliPayCallBackEvent" object:dic];
//        }
//    }
//    return YES;
//}

@end
